﻿@model PagedList.IPagedList<EventPlanner.Models.AuditInfo>
<div class="navigation">
    @{
        if (Model.HasPreviousPage)
        {
            @Html.ActionLink("««", ViewContext.RouteData.GetRequiredString("action"),
                new { page = 1, sortOrder = Request.Params.Get("sortOrder"), currentFilter = Request.Params.Get("currentFilter") },
                new { @class = "navigation" })
            @Html.ActionLink("«", ViewContext.RouteData.GetRequiredString("action"),
                     new { page = Model.PageNumber - 1, sortOrder = Request.Params.Get("sortOrder"), currentFilter = Request.Params.Get("currentFilter") },
                new { @class = "navigation" })
        }
        else
        {<a class="navigation-inhabilitado">««</a><a class="navigation-inhabilitado">«</a>}
        int offset = Model.PageNumber - 3;
        if (offset < 0)
        {
            offset = 0;
        }
        int max = 5;
        if(Model.PageCount < 5)
        {
            max = Model.PageCount;
        }
        if (offset + max > Model.PageCount)
        {
            offset = Model.PageCount - max;
        }
        for (int i = 1 + offset; i <= max + offset; i++)
        {
            string nav = "navigation";
            if(i == Model.PageNumber)
            {
                nav = "navigation-selected";
            }
            @Html.ActionLink("" + i, ViewContext.RouteData.GetRequiredString("action"),
                new { page = i, sortOrder = Request.Params.Get("sortOrder"), currentFilter = Request.Params.Get("currentFilter") },
                new { @class = nav })
        }

        if (Model.HasNextPage)
        {
            @Html.ActionLink("»", ViewContext.RouteData.GetRequiredString("action"),
                new { page = Model.PageNumber + 1, sortOrder = Request.Params.Get("sortOrder"), currentFilter = Request.Params.Get("currentFilter") },
                new { @class = "navigation" })
            @Html.ActionLink("»»", ViewContext.RouteData.GetRequiredString("action"),
                new { page = Model.PageCount, sortOrder = Request.Params.Get("sortOrder"), currentFilter = Request.Params.Get("currentFilter") },
                new { @class = "navigation" })
        }
        else
        {<a class="navigation-inhabilitado">»</a><a class="navigation-inhabilitado">»»</a>}
    }
</div>
